include('shared.lua')

local matLight 		= Material( "sprites/light_ignorez" )

function ENT:Initialize()
	self.PixVis = util.GetPixelVisibleHandle()
    
    self.LightAttachment = Vector(4.50, -12.80, 43.00)

	self.BaseClass.Initialize( self )
end

function ENT:GetLightColor( visible )

	if self:Building() then
		return Color(255,0,0, 255 * visible)
	end
	
	return Color(0,255,0, 255 * visible)

end

function ENT:Draw()
	self.BaseClass.Draw( self )
	
	local LightPos = self:LocalToWorld( self.LightAttachment )
	local Visibile	= util.PixelVisible( LightPos, 4, self.PixVis )
	
	if Visibile then
		render.SetMaterial( matLight )
		render.DrawSprite( LightPos , 8, 8, self:GetLightColor( Visibile ) )
	end
end